Part Number Hot Search : 
05203GOC LSI20 MURHB840 CD214 91HA14 AD539JN GW20N S3C7559
Product Description
Full Text Search
 

To Download AN184-1 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
 AN184
Application Note
EP72XX INTERFACE TO MULTIMEDIACARD
P.O. Box 17847, Austin, Texas 78760 (512) 445 7222 FAX: (512) 445 7581 http://www.cirrus.com
Copyright (c) Cirrus Logic, Inc. 2000 (All Rights Reserved)
AUG `00 AN184REV1 1
AN184
TABLE OF CONTENTS
1. INTRODUCTION ....................................................................................................................... 3 2. BACKGROUND ........................................................................................................................ 3 3. MMC MODE VIRTUAL PERIPHERAL SOLUTION .................................................................. 3 3.1 Sample Code: MMC Interface Connection ........................................................................ 4 4. SPI MODE VIRTUAL PERIPHERAL ........................................................................................ 6 4.1 Sample Code: Sending Data to MMC Using SPI Mode ..................................................... 7 5. CONCLUSION .......................................................................................................................... 8 6. REFERENCES .......................................................................................................................... 8
LIST OF FIGURES
Figure 1. MMC in MMC mode ......................................................................................................... 5 Figure 2. Waveform Measurement Results of send_mmc_byte. .................................................... 5 Figure 3. MMC in SPI Mode ............................................................................................................ 6
Contacting Cirrus Logic Support
For a complete listing of Direct Sales, Distributor, and Sales Representative contacts, visit the Cirrus Logic web site at: http://www.cirrus.com/corporate/contacts/
Preliminary product information describes products which are in production, but for which full characterization data is not yet available. Advance product information describes products which are in development and subject to development changes. Cirrus Logic, Inc. has made best efforts to ensure that the information contained in this document is accurate and reliable. However, the information is subject to change without notice and is provided "AS IS" without warranty of any kind (express or implied). No responsibility is assumed by Cirrus Logic, Inc. for the use of this information, nor for infringements of patents or other rights of third parties. This document is the property of Cirrus Logic, Inc. and implies no license under patents, copyrights, trademarks, or trade secrets. No part of this publication may be copied, reproduced, stored in a retrieval system, or transmitted, in any form or by any means (electronic, mechanical, photographic, or otherwise) without the prior written consent of Cirrus Logic, Inc. Items from any Cirrus Logic web site or disk may be printed for use by the user. However, no part of the printout or electronic files may be copied, reproduced, stored in a retrieval system, or transmitted, in any form or by any means (electronic, mechanical, photographic, or otherwise) without the prior written consent of Cirrus Logic, Inc.Furthermore, no part of this publication may be used as a basis for manufacture or sale of any items without the prior written consent of Cirrus Logic, Inc. The names of products of Cirrus Logic, Inc. or other vendors and suppliers appearing in this document may be trademarks or service marks of their respective owners which may be registered in some jurisdictions. A list of Cirrus Logic, Inc. trademarks and service marks can be found at http://www.cirrus.com.
2
AN184REV1
AN184
1. INTRODUCTION
This application note describes a simple interface between a Cirrus Logic EP72XX microcontroller and a MultiMediaCard. The MultiMediaCard (MMC) is a universal lowcost data storage and communication media. It is designed to cover a wide area of applications such as electronic toys, organizers, PDAs, cameras, smart phones, digital recorders, and digital players (such as MP3). The MMC communication is based on a 7-pin serial bus designed to operate in a low voltage range. A MMC communication protocol is defined as part of the standard and is referred to as MMC mode. For compatibility, an alternate communication protocol (a subset of MMC) is based on the SPITM (Serial Peripheral Interface) standard. This application note will describe a method to support both modes. The EP72xx microcontrollers have a speed-limited SPI port. Though adequate for reading content (at least up to 128 kbits/s), it is too slow for writing. However, the high speed of the ARM(R) processor allows one to create a "virtual peripheral" to support both SPI and MMC modes. A software "bit-bang" method provides the necessary signals for data and command, while a chip select provides the clock. Transfer speed using this method approaches 3 Mbits/s. For future applications, the SD MMC (secure MMC) bus has added 3 more data lines so that 4-bits can be transferred per clock (instead of one). This should eventually improve download speeds approaching that of traditional NAND flash.
3. MMC MODE VIRTUAL PERIPHERAL SOLUTION
Two GPIO pins are used for MMC_Data and MMC_Command. A spare chip select line is used for MMC_Clock. Section 3.1, "Sample Code: MMC Interface Connection" contains sample code that illustrates a possible connection to the MMC interface. In this case, GPIO pin PA7 is used for MMC_Data and PA6 is used for MMC_Command. A schematic is shown in Figure 1. To maximize transfer speed, the routine to send bytes to the MMC card should be written in assembly language. For illustrative purposes, the sample code is written in C with in-line assembly. Note that the code is "unrolled", i.e. it does not use a loop counter to set the number of bits transmitted (in this case, one byte or 8 bits). Doing so adds substantially more overhead. As shown, it takes 23 instructions to execute the main routine. This routine, when running out of cache, should be able to burst at 74/23 MHz, or approximately 3 Mbs (see Figure 2). Using a loop counter will add two extra instructions per iteration, plus another cycle for the conditional branch, for a total of 8 * (3 + 2) = 40 cycles, or about 1/2 the speed of the unrolled loop.
2. BACKGROUND
For digital audio applications such as portable MP3 players, the digital content is typically stored in NAND Flash memory. The MMC offers an alternative storage media and has the advantage of being removable and portable. For operation using the SPI protocol, the host must be able to read data at a typical MP3 data rate of 128 kilo-bits-persecond (kbits/s). For programming the MMC, 128 kbits/s rate is insufficient to provide short download times. A typical portable MP3 system may include a USB port that accepts MP3 data files from a host PC. Since USB is a relatively fast interface with bit rates approaching 5 Mbits/s average rate (due to operating system overhead), the main limitation to download speed is the speed at which the MMC can be programmed. First versions of MMC cards can be programmed at ~1 Mbits/s, or around 125 kbytes/s. Newer generations of MMC cards are expected to reach 2.5 Mbits/s, or ~400 kbytes/s
AN184REV1
3
AN184
NOTE: The nCS5 byte field in MEMCFG2 = 0x3E. Chip select 5 is not cached and the write buffer is disabled.)
3.1 Sample Code: MMC Interface Connection
// Routine to send a bit stream to MMC card. // Data to send is in R0, address of nCS5 is in R1, and GPIO address is in R2. // For this example, R1=0x5000.0000, R2=0x8000.0000 (port A data register). // It is also assumed that PA7 is an output and pins PA[6:0] are input prior // to calling this function. Data is sent MSB first. void send_mmc_byte(char mmc_data, int port, int GPIO) { __asm { strb r0, [r2] // get value and place in GPIO strb r0, [r1] // strobe cs5 mov r0, r0, lsl #1 // shift next bit left which places it in PA7. strb r0, [r2] // Repeat 7 more times. strb r0, [r1] mov r0, r0, lsl #1 strb r0, [r2] strb r0, [r1] mov r0, r0, lsl #1 strb r0, [r2] strb r0, [r1] mov r0, r0, lsl #1 strb r0, [r2] strb r0, [r1] mov r0, r0, lsl #1 strb r0, [r2] strb r0, [r1] mov r0, r0, lsl #1 strb r0, [r2] strb r0, [r1] mov r0, r0, lsl #1 strb r0, [r2] strb r0, [r1] } }
4
AN184REV1
AN184
3.3V
U? 51K PA[6] nCS5 PA[7] 51K 1 2 3 4 5 6 7 RSV CMD Vss Vdd CLK Vss2 DAT[0] MMC Connector
Figure 1. MMC in MMC mode
Figure 2. Waveform Measurement Results of send_mmc_byte.
AN184REV1
5
AN184
4. SPI MODE VIRTUAL PERIPHERAL
To implement a SPI port, three GPIO signals are needed: chip select, data out, and data in. As with the MMC interface, nCS5 is used for the SPI data clock. A schematic is shown in Figure 3. A C subroutine with in-line assembly to write an 8-bit byte of data to the MMC is shown below. Unlike the previous sample code example, the routine in Section 4.1, "Sample Code: Sending Data to MMC Using SPI Mode" uses a loop counter. Better performance can be achieved if the loop is unrolled. This is left as an exercise for the reader. Both Virtual Peripheral examples were written using the ARM Tools Version 2.50. Code results were benchmarked on a Cirrus Logic EP7209 evaluation board running the Angel Debug Monitor. In some cases, it is desired to be able to support both modes of MMC operation, i.e., SPI and MMC modes. In this case, it is necessary to provide a power switch to the MMC power supply. Upon power up, the MMC defaults to MMC mode. To set for SPI mode, a command is issued to the card. Once in SPI mode, the MMC cannot revert back to MMC Mode until power is recycled.
3.3V
U?
PE[0] PA[7] nCS5 PA[6]
1 2 3 4 5 6 7
nCS DI Vss Vdd SCLK Vss2 DO MMC Connector
Figure 3. MMC in SPI Mode
6
AN184REV1
AN184
4.1 Sample Code: Sending Data to MMC Using SPI Mode
// // // // // // // // // Routine to send a bit stream to the MMC card using the SPI mode. Data to send is in R0, address of nCS5 in R1 (in this case, 0x5000.0000), and R2 contains address of GPIO (Port A). It is also assumed that PA7 is an output and pins PA[6:0] are input prior to calling this function. In addition, the MMC chip select must be asserted (set to low) prior to using this routine. If a PA bit is used for CS, added instructions and registers are required to mask off the CS bit and will affect transfer speed. Data is sent MSB first. void send_spi_byte(char spi_data, int port, int GPIO) { __asm { mov r3, #0x8 //loop counter s1: strb r0, [r2] // output bit to PA7 strb r0, [r1] // and strobe nCS5 mov r0, r0, lsl #1 // get next bit by shifting left once subs r3, r3, #1 // are all bits transferred? bne s1 // no. branch back } }
AN184REV1
7
AN184
5. CONCLUSION
Using the fast instruction set of the ARM7 and by careful design of software, it is possible to generate a software virtual peripheral that can interface to a MMC memory card using either the MMC or SPI interface protocol. Speeds up to 3 Mbit/s can be achieved in this manner, which is adequate for most applications. For best performance, follow these guidelines:
Data read or written should use the multiple block mode for data transfer. Some MMC cards will not support multiple block mode with the SPI interface Use MMC mode if possible. Be aware that it can take as long as 2.5 mS after a command is sent to the MMC before it is ready to send data. This is referred to as the NAC access time delay. Keep a flat file structure on the MMC so that blocks are contiguous thereby minimizing NAC Unroll all assembly loops Try to design with the fastest and widest program memory possible. This will improve overall speed.
6. REFERENCES
Information on the MMC specifications can be found at the MultiMediaCard Association Web site www.mmca.org. Data sheets for MMC cards can be found at several locations. Start by trying www.sandisk.com. Information on Cirrus Logic's ARM-based microcontrollers, including data sheets on the EP7209/12 can be found at www.cirrus.com.
-
-
8
AN184REV1
* Notes *
1


▲Up To Search▲   

 
Price & Availability of AN184-1

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X